//
//  LGSeviceStatisticsHeaderView.m
//  HeartDiseaseManage
//
//  Created by 1234 on 2023/5/8.
//

#import "LGSeviceStatisticsHeader.h"
#import "LGSeviceStatisticsItem.h"
#define itemW   (Screen_W-viewPix(32))/3.0

#define itemH   viewPix(70)

@interface LGSeviceStatisticsHeader()
/**   */
@property (nonatomic , strong)UIView *baseView;
/**   */
@property (nonatomic , strong)UILabel *titleLabel;
/**   */
@property (nonatomic , strong)LGSeviceStatisticsItem *patientItem;
/**   */
@property (nonatomic , strong)LGSeviceStatisticsItem *serviceItem;
/**   */
@property (nonatomic , strong)LGSeviceStatisticsItem *offlineItem;
/**   */
@property (nonatomic , strong)LGSeviceStatisticsItem *videoItem1;
/**   */
@property (nonatomic , strong)LGSeviceStatisticsItem *videoItem2;
/**   */
@property (nonatomic , strong)LGSeviceStatisticsItem *expertItem1;
/**   */
@property (nonatomic , strong)LGSeviceStatisticsItem *expertItem2;

@end

@implementation LGSeviceStatisticsHeader

- (instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = [UIColor clearColor];
        [self addSubview:self.baseView];
        [self.baseView addSubview:self.titleLabel];
        [self.baseView addSubview:self.patientItem];
        [self.baseView addSubview:self.serviceItem];
        [self.baseView addSubview:self.offlineItem];
        [self.baseView addSubview:self.videoItem1];
        [self.baseView addSubview:self.videoItem2];
        [self.baseView addSubview:self.expertItem1];
        [self.baseView addSubview:self.expertItem2];
    }
    return self;
}

-(void)setDataDic:(NSDictionary *)dataDic{
    _dataDic = dataDic;
    self.patientItem.content = LGNSString(dataDic[@"patient_count"]);
    self.serviceItem.content = LGNSString(dataDic[@"vip_count"]);
    self.offlineItem.content = LGNSString(dataDic[@"clinic_appoint_count"]);
    self.videoItem1.content = LGNSString(dataDic[@"video_cash_appoint_count"]);
    self.videoItem2.content = LGNSString(dataDic[@"video_vip_appoint_count"]);
    self.expertItem1.content = LGNSString(dataDic[@"expert_cash_appoint_count"]);
    self.expertItem2.content = LGNSString(dataDic[@"expert_vip_appoint_count"]);
}


#pragma mark
#pragma mark ====> 创建控件
-(UIView *)baseView{
    if(!_baseView){
        _baseView = [UIView shadowViewWithColor:@"#B2BDC7" offset:CGSizeMake(0, 2) opacity:0.1 radius:10];
        _baseView.frame = CGRectMake(viewPix(16), viewPix(8), Screen_W-viewPix(32), viewPix(249));
        _baseView.backgroundColor = [UIColor whiteColor];
    }
    return _baseView;
}
-(UILabel *)titleLabel{
    if(!_titleLabel){
        _titleLabel = [UILabel lableWithText:@"个人统计" colorString:@"#000000" textFont:LGFontWeight(16, UIFontWeightSemibold) textAlignment:NSTextAlignmentLeft lines:1];
        _titleLabel.frame = CGRectMake(viewPix(16), viewPix(12), viewPix(150), viewPix(22));
    }
    return _titleLabel;
}

-(LGSeviceStatisticsItem *)patientItem{
    if(!_patientItem){
        _patientItem = [[LGSeviceStatisticsItem alloc]initWithFrame:CGRectMake(0, viewPix(40), itemW, itemH)];
        _patientItem.title = @"新增患者";
        _patientItem.content = @"0";
    }
    return _patientItem;
}

-(LGSeviceStatisticsItem *)serviceItem{
    if(!_serviceItem){
        _serviceItem = [[LGSeviceStatisticsItem alloc]initWithFrame:CGRectMake(kMaxX(self.patientItem.frame), kMinY(self.patientItem.frame), itemW, itemH)];
        _serviceItem.title = @"新增服务包";
        _serviceItem.content = @"0";
    }
    return _serviceItem;
}

-(LGSeviceStatisticsItem *)offlineItem{
    if(!_offlineItem){
        _offlineItem = [[LGSeviceStatisticsItem alloc]initWithFrame:CGRectMake(kMaxX(self.serviceItem.frame), kMinY(self.patientItem.frame), itemW, itemH)];
        _offlineItem.title = @"线下复查";
        _offlineItem.content = @"0";
    }
    return _offlineItem;
}

-(LGSeviceStatisticsItem *)videoItem1{
    if(!_videoItem1){
        _videoItem1 = [[LGSeviceStatisticsItem alloc]initWithFrame:CGRectMake(0, kMaxY(self.patientItem.frame), itemW, itemH)];
        _videoItem1.title = @"视频咨询(免费)";
        _videoItem1.content = @"0";
    }
    return _videoItem1;
}

-(LGSeviceStatisticsItem *)videoItem2{
    if(!_videoItem2){
        _videoItem2 = [[LGSeviceStatisticsItem alloc]initWithFrame:CGRectMake(kMaxX(self.videoItem1.frame), kMinY(self.videoItem1.frame), itemW, itemH)];
        _videoItem2.title = @"视频咨询(付费)";
        _videoItem2.content = @"0";
    }
    return _videoItem2;
}

-(LGSeviceStatisticsItem *)expertItem1{
    if(!_expertItem1){
        _expertItem1 = [[LGSeviceStatisticsItem alloc]initWithFrame:CGRectMake(0, kMaxY(self.videoItem1.frame), itemW, itemH)];
        _expertItem1.title = @"专家咨询(免费)";
        _expertItem1.content = @"0";
    }
    return _expertItem1;
}

-(LGSeviceStatisticsItem *)expertItem2{
    if(!_expertItem2){
        _expertItem2 = [[LGSeviceStatisticsItem alloc]initWithFrame:CGRectMake(kMaxX(self.expertItem1.frame), kMinY(self.expertItem1.frame), itemW, itemH)];
        _expertItem2.title = @"专家咨询(付费)";
        _expertItem2.content = @"0";
    }
    return _expertItem2;
}

@end
